<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<title>实名认证</title>
		<link href="plugin/date/date.css" rel="stylesheet">
		<link href="bootstrap/css/bootstrap3.min.css" rel="stylesheet">
		<link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
		<script src="js/jquery.min.js"></script>
		<link rel="stylesheet" href="css/nav.css" />
		<style>
			.form-group-update {
				margin-right: 2%;
			}
			.imgsBox  {display: inline-block; margin-right: 5px; margin-top: 5px;}
			.imgsBox img{ width: 100px;}
		</style>
	</head>

	<body>
		<!--导航-->
	    <nav class="navbar navbar-inverse">
	      <div class="container-fluid">
	        <div class="navbar-header">
	          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-2">
	            <span class="sr-only">Toggle navigation</span>
	            <span class="icon-bar"></span>
	            <span class="icon-bar"></span>
	            <span class="icon-bar"></span>
	          </button>
		          	<a class="navbar-brand" href=""><img src="images/admin_logo.png" alt=""></a>
	        </div>

	        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
	          <ul class="nav navbar-nav" id="nav">

	          </ul>
	          <ul class="nav navbar-nav navbar-right">
	            <li class="dropdown">
	              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">欢迎您：<span id="uname"></span><span class="caret"></span></a>
	              <ul class="dropdown-menu" role="menu">
	                <li><a href="change_pass.html">修改密码</a></li>
	                <li><a id="loginOut" href="#">退出登陆</a></li>
	              </ul>
	            </li>
	          </ul>
	        </div>
	      </div>
	    </nav>
		<div class="container-fluid">
			<div class="row bcert-box">
				<ol class="breadcrumb">
				  <li><a href="javascript:;">主页</a></li>
				  <li>会员管理</li>
				  <li class="active">实名认证</li>
				</ol>
				<form class="form-inline searchForm" id="excleBtn">
		          <div class="form-group">
		            <span class="theme-title">审核状态:</span>
		            <select class="form-control drop-down" name='status' id="status">
		              <option value="">全部</option>
		              <option value="0">待审核</option>
		              <option value="1">审核通过</option>
					  <option value="2">审核不通过</option>
		            </select>
		          </div>
		          <div class="form-group">
		              <input type="text" class="form-control" style="padding-left:12px;" name="name" id="name" placeholder="会员名称">
		          </div>
		          <div class="form-group">
		              <input type="text" class="form-control" style="padding-left:12px;" name="trueName" id="trueName" placeholder="真实姓名">
		          </div>
		          <div class="form-group">
		            <!-- <button type="button" class="btn btn-primary btn-success" id="Reset"></span>重置</button> -->
		            <button type="button" class="btn btn-primary btn-default" id="QueryBtn" data-toggle="button" aria-pressed="false" autocomplete="off">查询</button>
		            <!-- <button type="button" class="btn btn-primary btn-success" id="dlexcle"></span>&nbsp;导出excle</button> -->
		          </div>
		        </form>
				<div class="table">
		          <table class="table table-bordered table-striped" id="dataList">

		          </table>
		        </div>
		      </div>
		      <!-- 分页 -->
		        <nav aria-label="...">
		          <div class="">
		            <span id="pageNum">共&nbsp;<strong></strong>&nbsp;页&nbsp;/&nbsp;</span><span id="totalNum">&nbsp;<strong>0</strong>&nbsp;条数据</span>
		          </div>
		          <ul id="example"></ul>
		        </nav>
			</div>
		</div>
		<div class="modal fade" tabindex="-1" role="dialog" id="gridSystemModal" aria-labelledby="gridSystemModalLabel">
	    <div class="modal-dialog" role="document">
	        <div class="modal-content ztreeIpt">
	            <div class="modal-header">
	                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
	                </button>
	                 <h4 class="modal-title" id="gridSystemModalLabel">详情</h4>
	            </div>
	            <div class="modal-body" id="getRealInfo">

	            </div>
				<!--待审核-->
	            <div class="modal-footer" id="certificationAudit" style="display:none">
	                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" data-id="" class="btn btn-danger" onclick="nonApproval($(this).attr('data-id'),2)" id="noPass">审核不通过</button>
	                <button type="button" data-id="" class="btn btn-primary" onclick="auditApproval($(this).attr('data-id'),1)" id="pass">审核通过</button>
	            </div>
	        </div>
		        <!-- /.modal-content -->
	    </div>
	    <!-- /.modal-dialog -->
	</div>
	</body>
</html>
<script type="text/javascript" src="plugin/layer/layer.js"></script>
<script type="text/javascript" src="js/cookie.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript" src="js/bootstrap-paginator.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<script>
	var pageUrls = serverURL + '/platform/queryRealData';
	function tableList(){
		data = {
			'name':$('#name').val(),
			'trueName':$('#trueName').val(),
			'status':$('#status').val(),
			'page': page,
			'pageSize': pagesize
		}
		data.page = 1
		ajax(
			pageUrls,
			data,
			pageNumList,
			'post',
			'json'
		)
	}
	$('#QueryBtn').click(function(){
		tableList()
	})
	$(document).ready(function() {
		tableList()
	});
	//数据渲染
	function OpendList(res){
	    var result = '';
		console.log(res)
	    $('#dataList').empty();
	    $('#dataList').append(
	      '<tr>' +
	      '<th>会员id</th>' +
	      '<th>会员名称</th>' +
	      '<th>真实姓名</th>' +
	      '<th>证件号</th>' +
		  '<th>申请时间</th>' +
	      '<th>审核状态</th>' +
		  '<th>操作</th>' +
	      '</tr>'
	    );
	    for (var i = 0; i < res.data.list.length; i++) {
	        var time = getMyDate(res.data.list[i].createTime);
	        result +=
	               '<tr>'+
	                 '<td>'+ res.data.list[i].id +'</td>'+
	                 '<td>'+ res.data.list[i].memberName +'</td>'+
	                 '<td>'+ res.data.list[i].cardName +'</td>'+
	                 '<td>'+ res.data.list[i].cardNumber +'</td>'+
	                 '<td>'+ res.data.list[i].addTime +'</td>'
					 if (res.data.list[i].status == 1) {
						result +='<td>审核通过</td>'
					}else if (res.data.list[i].status == 0) {
						result +='<td>待审核</td>'
					}else if (res.data.list[i].status == 2) {
						result +='<td>审核不通过</td>'
					}
				 	result +='<td><button type="button" data-id="'+ res.data.list[i].id +'"  class="btn btn-sm btn-primary btn-lg particularsBtn" data-toggle="modal">查看</button>'+

	               '</td></tr>'
	    }
	    $('#dataList').append(result)
	  }

	//数据详情
	 $(document).on('click', '.particularsBtn', function() {
		var html = ''
		$('#gridSystemModal').modal();
	 	id = $(this).attr('data-id')
		$('#pass').attr('data-id',id)
		$('#noPass').attr('data-id',id)
		var data = {
			'id':id
		}
		var cbk = function(res){
			// layer.msg(data.mag)
			$('#getRealInfo').empty()
			var cardType = res.data.cardType
			if(cardType == 1){
				cardType = '身份证'
			}else if (cardType == 2) {
				cardType = '护照'
			}else if (cardType == 3) {
				cardType = '军官证'
			}else if (cardType == 4) {
				cardType = '港澳居民来往内地通行证'
			}else if (cardType == 5) {
				cardType = '台胞证'
			}else{
				cardType = '其他'
			}
			var status = res.data.status
			if(status== 0){
				status = '审核中';
				$('#certificationAudit').show()
			}else if (status== 1) {
				status = '审核通过'
			}else{
				status = '审核不通过'
			}
		    html += '<table class="table table-bordered table-condensed tableCon layer-photos-demo">'+
'					<tbody>'+
'					<tr>'+
'						<th style="background-color: #f9f9f9;">记录编号：</th>'+
'						<td id="">'+ res.data.realId +'</td>'+
'					</tr>'+
'					<tr>'+
'						<th style="background-color: #f9f9f9;">会员id：</th>'+
'						<td id="">'+ res.data.memberId +'</td>'+
'					</tr>'+
'					<tr>'+
'						<th style="background-color: #f9f9f9;">证件类型：</th>'+
'						<td id="">'+ cardType +'</td>'+
'					</tr>'+
'					<tr>'+
'						<th style="background-color: #f9f9f9;">真实姓名：</th>'+
'						<td id="">'+ res.data.cardName +'</td>'+
'					</tr>'+
'					<tr>'+
'						<th style="background-color: #f9f9f9;">证件号码：</th>'+
'						<td id="">'+ res.data.cardNumber+'</td>'+
'					</tr>'+
'					<tr>'+
'						<th style="background-color: #f9f9f9;">证件照片正面：</th>'+
'						<td id=""><div class="imgsBox"><img class="img-thumbnail" src="'+ cncbk_common_tools.imgURL + res.data.cardImg1 +'" alt=""></div></td>'+
'					<tr>'+
'					</tr>'+
'						<th style="background-color: #f9f9f9;">证件照片反面：</th>'+
'						<td id=""><div class="imgsBox"><img class="img-thumbnail" src="'+ cncbk_common_tools.imgURL + res.data.cardImg2 +'" alt=""></div></td>'+
'					</tr>'+
'					<tr>'+
'						<th style="background-color: #f9f9f9;">证件照片手持：</th>'+
'						<td id=""><div class="imgsBox"><img class="img-thumbnail" src="'+ cncbk_common_tools.imgURL + res.data.cardImg3 +'" alt=""></div></td>'+
'					</tr>'+
// '					<tr>'+
// '						<th style="background-color: #f9f9f9;">申请用户类型：</th>'+
// '						<td id="">'+ res.data.memberType +'</td>'+
// '					</tr>'+
// '					<tr>'+
// '						<th style="background-color: #f9f9f9;">证件认证状态：</th>'+
// '						<td id="">'+ res.data.checkStatus +'</td>'+
// '					</tr>'+
// '					<tr>'+
// '						<th style="background-color: #f9f9f9;">证件认证时间：</th>'+
// '						<td id="">'+ res.data.checkTime +'</td>'+
// '					</tr>'+
'					<tr>'+
'						<th style="background-color: #f9f9f9;">审核状态：</th>'+
'						<td id="">'+ status +'</td>'+
'					</tr>'
				if(res.data.status == 2){
					html +=
					'<tr>'+
					'<th style="background-color: #f9f9f9;">审核不通过原因：</th>'+
					'<td id="">'+ res.data.cause +'</td>'+
					'</tr>'
				}
				//
		html +='</tbody>'+
				'</table>'
			$('#getRealInfo').append(html)
		}
		ajax(
			serverURL +'/platform/getRealInfo',
			data,
			cbk,
			'post',
			'json'
		)
	 })
	//通过审核
	function auditApproval(id,status){
		layer.confirm('确定要审核通过？', {
  		  btn: ['确定','取消'] //按钮
  		}, function(){
			var data= {
				'id':id,
				'status':status,
			}
			var cbk = function (res){
				layer.msg(res.msg)
				tableList()
				$('#gridSystemModal').modal('hide')
			}
			ajax(
				serverURL+'/platform/checkMemberReal',
				data,
				cbk,
				'post',
				'json'
			)
  		}, function(){

  		});
	}
	function nonApproval(id,status){
		$('#gridSystemModal').modal('hide')
		layer.prompt({title: '请填写审核不通过原因', formType: 2}, function(text, index){
		    layer.close(index);
			var data= {
				'id':id,
				'status':status,
				'cause':text,
			}
			var cbk = function (res){
				layer.msg(res.msg)
				tableList()
			}
			ajax(
				serverURL+'/platform/checkMemberReal',
				data,
				cbk,
				'post',
				'json'
			)
		});
	}
	//数据清空
	$('#gridSystemModal').on('hidden.bs.modal', function (e) {
		$('#certificationAudit').hide()
	})

</script>
